﻿using Microsoft.Extensions.DependencyInjection;
using Quartz;
using Quartz.Spi;

namespace SBlogCore.TaskJob
{
    public class SBlogCoreJobFactory:IJobFactory
    {
        private readonly IServiceProvider _serviceProvider;

        public SBlogCoreJobFactory(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var res = (IJob) _serviceProvider.GetRequiredService(bundle.JobDetail.JobType);
            return res;
        }
        /// <summary>
        /// 允许作业工厂根据需要销毁/清理作业。
        /// </summary>
        /// <param name="job"></param>
        public void ReturnJob(IJob job)
        {
           
        }
    }
}
